package com.example.bootintegration.service;

import org.springframework.retry.annotation.Recover;
import org.springframework.retry.annotation.Retryable;
import org.springframework.stereotype.Service;

/**
 * @author Quintoy
 * @date 01/04/24
 */
@Service
public class RetryTest {

    @Retryable(value = RuntimeException.class, maxAttempts = 2)
    public void testRetry() {
        System.out.println("test exception.");
        throw new RuntimeException("xxx");
    }

    @Recover
    public void recover06(RuntimeException e) {
        System.out.println("兜底方法开启,异常信息:" + e.getMessage());
    }
}
